You are here: Building the Model: General Elements > Pre-defined Tank Subroutines > Examples of Tank Control Logic > Tank Transfers
When transferring from one tank to another, you must determine whether the source tank makes the decision to transfer to the destination tank (a push approach) or whether the destination tank makes the decision to draw material from a source tank (a pull approach). You should define a control subroutine from the perspective of the tank that makes the decision. If the model requires no tank selection, specify a WAIT UNTIL statement to wait until the FROM or TO tank satisfies the condition required for transfer. For example, if a source tank makes the decision to transfer to a destination tank whenever the destination tank becomes idle, enter the following statement in the subroutine:
Transfer contents when idle
Wait Until Tank_State [<destination tank ID>] = Tank_Idle
If the destination tank makes the decision to transfer (a pull approach), you should base the WAIT UNTIL statement on a required condition for the source tank as follows:
Transfer contents based on condition
Wait Until Tank_State [<source tank ID>] = Tank_Blocked
Following the WAIT UNTIL statement, call the Tank_Transfer, Tank_TransferUpTo, or Tank_TransferDownTo subroutine to transfer from the source tank to the destination tank.
To illustrate how to define a tank transfer using a pull approach, suppose that TankB requires 1000 gallons from TankA whenever TankB becomes empty. TankB will draw material from TankA only when TankA has a minimum level of 1000 gallons. The subroutine to define this logic might appear as follows:
Tank transfer in a pull system
Tank_Loop //logic repeats continuously
Begin
Wait Until Tank_Level[TankA] >= 1000 /*Wait for TankA to reach 1000 gallons*/
Tank_Transfer (TankA, TankB, 1000, 200,0,0) /* Transfer 1000 gal to TankB at 200 gpm*/
[Enter TankB processing and emptying logic here]
End
Please note
To select from among multiple input or output tanks, activate this subroutine in the initialization logic.